package org.example.myleet.rosalind.afrq;

import org.example.myleet.rosalind.utils.BigNumberOperator;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Solution {
    public static void main(String[] args) {
//        String input = "0.1 0.25 0.5";
        String input = "0.134000774948 0.896619548012 0.5964671134 0.466793336552 0.0952187263123 0.0839780656564 0.783356327869 0.940926352485 0.47634106456 0.346537607881 0.733449014675 0.0304567360708 0.358552904428 0.132151947326 0.989521373018 0.922256676954 0.305656890818 0.997049074837";
        String[] recessiveIndividualProbabilityArr = input.split(" ");
        for (String str : recessiveIndividualProbabilityArr) {
            BigDecimal recessiveIndividualProbability = new BigDecimal(str);
            BigDecimal recessiveAlleleProbability = BigNumberOperator.sqrt(recessiveIndividualProbability);
            BigDecimal dominantAlleleProbability = BigDecimal.ONE.subtract(recessiveAlleleProbability);
            BigDecimal recessiveAllelePossessingProbability = dominantAlleleProbability.multiply(recessiveAlleleProbability).multiply(new BigDecimal("2")).add(recessiveIndividualProbability);
            System.out.printf("%s ", recessiveAllelePossessingProbability.setScale(3, RoundingMode.HALF_UP).stripTrailingZeros());
        }
        System.out.println();
    }
}
